package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.Grad;
import com.ruoyi.system.mapper.GradMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/*
功能描述:
作者：14136
创造日期：2024/12/10
*/
@Service
public class GradServiceImpl implements GradService {
    @Resource
    private GradMapper gradMapper;

    @Override
    public List<Grad> selectGradList(Grad grad) {
        // 假设 gradList 方法不需要参数，直接调用
        return gradMapper.gradList();
    }

    @Override
    public Object selectGradById(Integer id) {

        return gradMapper.selectGradById(id);
    }

    @Override
    @Transactional
    public void save(@Valid Grad grad) {
        gradMapper.updateChineseGrades(grad);
        gradMapper.updateMathGrades(grad);
        gradMapper.updateEnglishGrades(grad);


    }

    @Override
    public void addSave(Grad grad) {
         gradMapper.add(grad);
    }

    @Override
    public AjaxResult deleteUserByIds(Integer[] ids) {
        for (Integer id:ids) gradMapper.delete(id);
        return null;
    }

    @Override
    public List<Grad> getStudentIds() {
        return gradMapper.getStudentIds();
    }


}
